package com.finance.cooperate.strategy.config;

import com.finance.cooperate.strategy.core.common.Builder;
import com.finance.cooperate.strategy.core.common.ConfigureProcessor;
import com.finance.cooperate.strategy.strategy.FraudStrategy;
import com.finance.cooperate.strategy.strategy.RePrefixRule;
import com.finance.cooperate.strategy.strategy.ScoreConvertStrategy;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;

/**
 * @ClassName StrategyConfig
 * @Description 线上策略配置
 * 同一个组内的策略结果回相互覆盖，不同组内的分数相互继承
 * @Author shenanxin
 * @Date 2023/8/23 16:02
 * @Modify ...
 */
@SuppressWarnings("all")
public class StrategyConfig extends ConfigureProcessor {

    @Autowired
    private FraudStrategy fraudStrategy;

    @Autowired
    private RePrefixRule rePrefixRule;

    @Autowired
    private ScoreConvertStrategy scoreConvertStrategy;

    @Override
    protected void configure(Builder builder) {

        builder
                .join()
                    .or(
                            // 通用规则
                            rePrefixRule
                    )
                .join()
                    .or(
                            // 反欺诈策略
                            fraudStrategy
                    )
                .join()
                    .or(
                            // 分数转化
                            scoreConvertStrategy
                    )
                .join()
                    .builder();

    }

    @Resource(name = "strategyBuilder")
    @Override
    public void setBuilder(Builder builder) {
        this.builder = builder;
    }
}
